import os
import shutil
import common.gyblog as log

LOG = log.get_logger()
PATH = '\\\\lcnas\\xishu16t2020_1\\choosefc2\\'
# PATH = r'\\lcnas\xishu16T_2022\07-FC2temp\\'
# PATH = r'D:\新建文件夹\failed\\'
# PATH = 'D:\workdir_2\\'

'''
重命名PATH下的文件/文件夹
'''
'''
-carib-1080p
-1pon-1080p
[thz.la]
[Thz.la]
[ThZu.Cc]
hhd800.com@
'''
def rename_mp4s(path):
    files = os.listdir(path)
    for file in files:
        f = file.replace('_GG5', '').replace('gg5.co@', '').replace('hhd800.com@', '').replace('-4K', '')
        # f = file.replace('-caribpr-1080p', '').replace('-carib-1080p', '')
        old_name = path + file
        new_name = path + f
        shutil.move(old_name, new_name)
        print('重命名文件：{},{}'.format(old_name, new_name))
        LOG.info('重命名文件：{},{}'.format(old_name, new_name))


def cut_file_name(path):
    print('cut_file_name 是危险操作，请确认！！！！！！！')
    input = 'Y'
    if input == 'Y' or input == 'y':
        files = os.listdir(path)
        for file in files:
            cut_len = len('116655.xyz caribbeancom-')
            old_name = path + file
            new_name = path + file[cut_len:]
            shutil.move(old_name, new_name)
            print('重命名文件：{},{}'.format(old_name, new_name))
            LOG.info('重命名文件：{},{}'.format(old_name, new_name))


if __name__ == '__main__':
    rename_mp4s(PATH)
    # cut_file_name(PATH)
